<!--企业安全环保基本信息表 compan-->
<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="120">
            <Row v-show="!switchFlag" class="query-form" >
               <!-- <Col span="8">
                    <FormItem label="伤亡人员姓名：">
                        <Input type="text" v-model="dataToQuery.victim"></Input>
                    </FormItem>
                </Col>-->
                <Col span="8">
                    <FormItem label="事故类别：">
                        <Select v-model="dataToQuery.accTypeId"  >
                            <Option v-for="item in typeList" :value="item.codingCodeId" :key="item.codingCodeId">{{  item.codingName  }}</Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="事故时间：">
                        <DatePicker class="query-form-el" v-model="sartDateQuery" format="yyyy-MM-dd" type="daterange" placement="bottom-end"
                                    style="width: 100%" @on-change="(date) => onSelectFieldQueryDateRange(date, 'sartDate')"	></DatePicker>
                    </FormItem>
                </Col>

                <Col span="8">
                    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
                    <Button @click="reseter" class="ivu-btn-reset"  >重置</Button>
                    <Button type="primary" class="ivu-btn-query"   icon="md-search"  @click="query">查询</Button>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
               <!-- <Col span="8">
                    <FormItem label="伤亡人员姓名：">
                        <Input type="text" v-model="dataToQuery.victim"></Input>
                    </FormItem>
                </Col>-->
                <Col span="8">
                    <FormItem label="事故类别：">
                        <Select v-model="dataToQuery.accTypeId"  >
                            <Option v-for="item in typeList" :value="item.codingCodeId" :key="item.codingCodeId">{{  item.codingName  }}</Option>
                        </Select>
                    </FormItem>
                </Col>


                <Col span="8">
                    <FormItem label="事故时间：">
                        <DatePicker class="query-form-el" v-model="sartDateQuery" format="yyyy-MM-dd" type="daterange" placement="bottom-end"
                                    style="width: 100%"  @on-change="(date) => onSelectFieldQueryDateRange(date, 'sartDate')"	></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="企业名称：">
                     <!--   <Input type="text" v-model="dataToQuery.orgName"></Input>-->
                        <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyName' :orgTree="true" :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                    </FormItem>
                </Col>

            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="伤害程度：">
                        <Select v-model="injuryLevels"  multiple :max-tag-count="1">
                            <Option v-for="item in injuryLeveList" :value="item.codingCodeId" :key="item.codingCodeId">{{  item.codingName  }}</Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="就业类型：">
                        <Select v-model="memberships" multiple :max-tag-count="2">
                            <Option v-for="item in membershipList" :value="item.codingCodeId" :key="item.codingCodeId">{{item.codingName}}</Option>
                        </Select>
                    </FormItem>
                </Col>

                <Col span="8" >
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reseter" class="ivu-btn-reset">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
        <!--    <Row class="query-form">
                <Col span="24">
                    <Button size="large"  class="ivu-btn-add" icon="md-add"  @click="addInfo">新增</Button>
                </Col>
            </Row>-->
        </Form>
        <Table ref='table' :height="tableHeight"  no-data-text="没有查询到相关数据!" @on-selection-change = 'getSelectRows' :loading='pageStatus.loading'
               border :columns="columns1"  :data="dataTable" >
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24" >
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange1" @on-page-size-change="pageSizeChange1" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </Col>
        </Row>
        <Modal  :title="mode == 'view' ?'事故统计月报详情':'事故统计月报'" :transfer=false :mask-closable="false" v-model="dialogShow" v-if="dataToView && dialogShow" :width=800 :styles="{height:'559px'}"  class-name='limit-height-dialog'>
            <Row>
                <Col span="24">
                    <Form ref="dataToView" :class="mode === 'view'?'modal-view-detail':'modal-form'" :show-message="false" :model="dataToView" :rules="mode === 'view'?{} :ruleCustom"  :label-position="mode === 'view'?'right':'top'" :label-width="mode === 'view'?160:null">
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='单位名称：' prop='reportOrgId'>
                                    <div v-if="mode === 'view'">{{ dataToView.reportOrgName }}</div>
<!--                                    <Input v-else class=''placeholder="请填写单位名称" type='text' v-model='dataToView.reportOrgName'></Input>-->
                                    <cascaderDom v-else  class="query-form-el" ref="reportOrgId"
                                                 @setOrgInfo='(data)=>{cascaderDomIdChangeHandle(data,"reportOrgId");}'
                                                 @setOrgname='(data)=>{cascaderDomNameChangeHandle(data,"reportOrgName");}'
                                                 :currentOrgId = "dataToView.reportOrgId"
                                                 :setCurrentName="{label:dataToView.reportOrgName, value:dataToView.reportOrgId}"
                                                 :orgTree="true"></cascaderDom>
                                </FormItem>
                            </Col>

                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='伤亡人员姓名：' prop='victim'>
                                    <div v-if="mode === 'view'">{{ dataToView.victim }}</div>
                                    <Input v-else class=''placeholder="请填写伤亡人员姓名" type='text' v-model='dataToView.victim' :readonly="true" @on-focus="openSelect"></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='性别：' prop='gender'>
                                    <div v-if="mode === 'view'">{{ dataToView.gender==='0'?'男':'女'}}</div>
                                    <Select v-else filterable v-model="dataToView.gender" placeholder="请选择性别">
                                        <Option v-for="item in genders" :value="item.valeue"
                                                :key="item.valeue">{{ item.name }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='年龄：' prop='age'>
                                    <div v-if="mode === 'view'">{{ dataToView.age }}</div>
                                    <InputNumber v-else class='w'placeholder="请填写年龄" min="0" type='text' v-model='dataToView.age'></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='事故时间：' prop='sartDate'>
                                    <div v-if="mode === 'view'">{{renderViewDate(dataToView.sartDate)}}</div>
                                    <DatePicker v-else class="w" placeholder="请选择事故时间" v-model='dataToView.sartDate' ></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='岗位或工种：' prop='position'>
                                    <div v-if="mode === 'view'">{{ dataToView.position }}</div>
                                    <Input v-else class=''placeholder="请填写岗位或工种" type='text' v-model='dataToView.position'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='伤害部位：' prop='injured'>
                                    <div v-if="mode === 'view'">{{ dataToView.injured }}</div>
                                    <Input v-else class=''placeholder="请填写伤害部位" type='text' v-model='dataToView.injured'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='事故类型：' prop='accTypeId'>
                                    <div v-if="mode === 'view'">{{ dataToView.accTypeName }}</div>
                                    <Select v-else  v-model="dataToView.accTypeId"
                                             placeholder="请选择事故类型">
                                        <Option v-for="item in typeList" :value="item.codingCodeId"
                                                :key="item.codingCodeId">{{ item.codingName }}
                                        </Option>
                                    </Select>

                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='伤害程度：' prop='injuryLevelId'>
                                    <div v-if="mode === 'view'">{{ dataToView.injuryLevelName }}</div>
                                    <Select  v-else v-model="dataToView.injuryLevelId"  placeholder="请填写伤害程度" >
                                        <Option v-for="item in injuryLeveList" :value="item.codingCodeId" :key="item.codingCodeId">{{  item.codingName  }}</Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='歇工天数：' prop='daysWokrOff'>
                                    <div v-if="mode === 'view'">{{ dataToView.daysWokrOff }}</div>
                                    <InputNumber v-else class='w'placeholder="请填写歇工天数" min="0" type='text' v-model='dataToView.daysWokrOff'></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='直接经济损失(万元)：' prop='loseMoney'>
                                    <div v-if="mode === 'view'">{{ dataToView.loseMoney }}</div>
                                    <Input v-else class=''placeholder="请填写0-9数字包括小数" type='text' v-model='dataToView.loseMoney'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='就业类型：' prop='membershipId'>
                                    <div v-if="mode === 'view'">{{ dataToView.membershipName }}</div>
                                    <Select v-else v-model="dataToView.membershipId" placeholder="请填写就业类型"  >
                                        <Option v-for="item in membershipList" :value="item.codingCodeId" :key="item.codingCodeId">{{item.codingName}}</Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='审核人：' prop='reviewer'>
                                    <div v-if="mode === 'view'">{{ dataToView.reviewerName }}</div>
                                    <cascaderDom v-else  class="query-form-el" ref="reviewer"
                                                 @setOrgInfo='(data)=>{cascaderDomIdChangeHandle(data,"reviewer");}'
                                                 @setOrgname='(data)=>{cascaderDomNameChangeHandle(data,"reviewerName");}'
                                                 :currentOrgId = "dataToView.reviewer"
                                                 :setCurrentName="{label:dataToView.reviewerName, value:dataToView.reviewer}"></cascaderDom>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row v-if="mode === 'view'" type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='创建人：' prop='userName'>
                                    <div >{{ dataToView.createUserName }}</div>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='创建时间：' prop='userName'>
                                    <div>{{ renderViewDate(dataToView.createDate)}}</div>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='事故描述：' prop='accDesc'>
                                    <div v-if="mode === 'view'">{{ dataToView.accDesc }}</div>
                                    <Input v-else class=''placeholder="请填写事故描述" type='textarea' v-model='dataToView.accDesc'></Input>
                                </FormItem>
                            </Col>

                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">

                            <Col span="23">
                                <FormItem label='备注：' prop='NOTE'>
                                    <div v-if="mode === 'view'">{{ dataToView.note }}</div>
                                    <Input v-else class=''placeholder="请填写备注" type='textarea' v-model='dataToView.note' ></Input>
                                </FormItem>

                            </Col>
                        </Row>

                    </Form>
                </Col>
            </Row>
            <div slot="footer">
                <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-save' @click="submit('dataToView')" >确定</Button>
                <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
                <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
            </div>
        </Modal>

        <Modal :transfer=false v-model="model3" :width=700 title="事故事件月报详情"  :styles="{height:'500px'}"  class-name='limit-height-dialog'>
            <Form :model="InputData" label-position="top">
                <Row style="line-height: 42px;margin-left: 20px">
                    <Row>
                        <Col span='11'>
                            <span>伤亡人员姓名：{{InputData.victim}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>性别：{{InputData.gender === '0'?'男':'女'}}</span>
                        </Col>
                    </Row>
                    <Row class="detail-background-clor">
                        <Col span='11'>
                            <span>年龄：{{InputData.age}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>工种或岗位：{{InputData.position}}</span>
                        </Col>
                    </Row>
                    <Row >
                        <Col span='11'>
                            <span>伤害部位：{{InputData.injured}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>事故时间：{{formatDate(new Date(InputData.sartDate), 'yyyy-MM-dd')}}</span>
                        </Col>
                    </Row>
                    <Row class="detail-background-clor" >
                        <Col span='11' >
                            <span>事故类别：{{InputData.accTypeName}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>就业类型：{{InputData.membershipName}}</span>
                        </Col>
                    </Row>
                    <Row >
                        <Col span='11'>
                            <span>伤害程度：{{InputData.injuryLevelName}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>创建人电话：{{InputData.contacterPhone}}</span>
                        </Col>
                    </Row>
                    <Row class="detail-background-clor">
                        <Col span='11'>
                            <span>创建人：{{InputData.userName}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>创建时间：{{formatDate(new Date(InputData.createDate), 'yyyy-MM-dd')}}</span>
                        </Col>
                    </Row>
                    <Row >
                        <Col span='23'>
                            <span>上报单位：{{InputData.orgName}}</span>
                        </Col>
                    </Row>
                    <Row class="detail-background-clor">
                        <Col span='11'>
                            <span>企业负责人：{{InputData.charge}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>二级集团安全环保管理人员：{{InputData.secondaryGroupPersion}}</span>
                        </Col>
                    </Row>
                    <Row >
                        <Col span='11'>
                            <span>集团安全环保管理人员：{{InputData.groupPersion}}</span>
                        </Col>
                        <Col span='11' offset="1">

                        </Col>
                    </Row>
                    <Row class="detail-background-clor">
                        <Col span='11'>
                            <span>歇工天数：{{InputData.daysWork}}</span>
                        </Col>
                        <Col span='11' offset="1">
                            <span>直接经济损失：{{InputData.loseMoney}}</span>
                        </Col>
                    </Row>

                    <Row >
                        <Col span='23' >
                            <span>初步原因分析：{{InputData.accAnalyze}}</span>
                        </Col>
                    </Row>
                    <Row class="detail-background-clor">
                        <Col span='23'>
                            <span>主要经过：{{InputData.accDesc}}</span>
                        </Col>
                    </Row>
                    <Row >
                        <Col span='23' >
                            <span>备注：{{InputData.notes}}</span>
                        </Col>
                    </Row>
                    <Row class="detail-background-clor" >
                        <Col span="23">
                            <FormItem label="伤亡事故简报表：">
                                <div v-show="uploadList.length>0" v-for="item in uploadList" :key='item'>
                                    <a @click="downloadFile(InputData.briefId,item)">{{ item.fileName }}</a>
                                </div>
                            </FormItem>
                        </Col>
                    </Row>
                </Row>
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="model3=false">关闭</Button>
            </div>
        </Modal>
        <Modal title="事故简报" :transfer=false footer-hide v-model="standardSelectModal" :width=900>
            <followReportForSelect ref="selMission" @getSelectData="selectStandard">
            </followReportForSelect>
        </Modal>
    </Layout>
</template>

<script>
import {Api} from '@/api/index.js'
import followReportForSelect from '../followReport/followReportForSelect.vue'
import pageCommonFunction from '@/components/pageCommonFunction.js'

var cascaderDom = () => import('@/components/cascader-dom.vue');
export default {
        components:{
            cascaderDom,followReportForSelect
        },
        data(){
            return {
                ...this.createCommonDataField(),
                model3:false,
                InputData:{},
                sartDateQuery:[],
                uploadList:[],
                stdRankList: [],
                memberships:[],
                injuryLevels:[],
                genders:[
                    {
                        name:"男",
                        valeue:"0"
                    },
                    {
                        name:"女",
                        valeue:"0"
                    }
                ],
              /*  columns1: [
                    { title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    { key:'reportOrgName',title: '单位名称',  align: 'center',minWidth:200 },
                    { key:'victim',title: '伤亡人员姓名',  align: 'center' ,minWidth:150 },
                    { key:'gender',title: '性别',minWidth:150, align: 'center',render: (h, params) => {return h('div', [params.row.gender === '0' ? '男' : '女']);}},
                    { key:'age',title: '年龄',  align: 'center',minWidth:150},
                    { key:'sartDate',title: '事故时间',  align: 'center' ,minWidth:200,render: this.renderCellDate},
                    { key:'position',title: '岗位或工种',  align: 'center',minWidth:150 },
                    { key:'injured',title: '伤害部位',  align: 'center',minWidth:150 },
                    { key:'accTypeName',title: '事故类型',  align: 'center' ,minWidth:150},
                    { key:'injuryLevelName',title: '伤害程度',  align: 'center',minWidth:150 },
                    { key:'daysWokrOff',title: '歇工天数',  align: 'center' ,minWidth:150},
                    { key:'loseMoney',title: '直接经济损失(万元)',  align: 'center' ,minWidth:150},
                    { key:'membershipName',title: '就业类型',  align: 'center',minWidth:150 },
                    { key:'reviewerName',title: '审核人',  align: 'center',minWidth:150 },
                 /!*   this.getActionColumns()*!/
                ],*/
                columns1: [
                    { title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    {
                        title: '伤亡人员姓名',
						fixed: 'left',
                        align: 'center',
                        key: 'victim',
                        minWidth:150,

                    },
                    {
                        title: '歇工天数',
                        align: 'center',
                        key: 'daysWork',
                        minWidth:150,

                    },
                    {
                        title: '直接经济损失(万元)',
                        align: 'center',
                        key: 'loseMoney',
                        minWidth:150,

                    },
                    {
                        title: '工种或岗位',
                        align: 'center',
                        key: 'position',
                        minWidth:150,

                    },
                    {
                        title: '事故时间',
                        align: 'center',
                        key: 'sartDateStr',
                        minWidth:150,
                    },
                    {
                        title: '事故类别',
                        align: 'center',
                        key: 'accTypeName',
                        minWidth:150,

                    },
                    {
                        title: '伤害程度',
                        align: 'center',
                        key: 'injuryLevelName',
                        minWidth:150,

                    },
                    {
                        title: '就业类型',
                        align: 'center',
                        key: 'membershipName',
                        minWidth:150,

                    },
                    {
                        title: '上报单位',
                        align: 'center',
                        key: 'orgName',
                        minWidth:300,
                        tooltip: true

                    },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.InputData = JSON.parse(JSON.stringify(params.row));
                                            this.getFiles()
                                            this.model3 = true;
                                        }
                                    }
                                }, '详情')])
                        }
                    }
                ],
                ruleCustom : {
                    reportOrgId: [ { required: true, message: '请选择单位', trigger: 'change',}],
                    victim: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.victim == null || this.dataToView.victim == '' || this.dataToView.victim == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    gender: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.gender == null || this.dataToView.gender == '' || this.dataToView.gender == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    age: [{
                        validator: (rule, value, callback) => {
                            if (!(/^([0-9][0-9]*)+(.[0-9]{1,4})?$/.test(this.dataToView.age))) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    sartDate: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.sartDate == null || this.dataToView.sartDate == '' || this.dataToView.sartDate == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    position: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.position == null || this.dataToView.position == '' || this.dataToView.position == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    injured: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.injured == null || this.dataToView.injured == '' || this.dataToView.injured == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    accTypeId: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.accTypeId == null || this.dataToView.accTypeId == '' || this.dataToView.accTypeId == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    injuryLevelId: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.injuryLevelId == null || this.dataToView.injuryLevelId == '' || this.dataToView.injuryLevelId == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    daysWokrOff: [ { required: true, message: '请填写歇工天数', trigger: 'change',type:'number'}],
                    loseMoney: [ { required: true, trigger: 'change',message:'请填写0-9数字包括小数',
                        validator: (rule, value, callback) => {
                            if (!(/^(([^0][0-9]+|0)\.([0-9]{1,2})$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]{1,2})$)|^(([1-9]+)$)/.test(value))) {
                                callback(' ');
                            } else {
                                callback()
                            }
                        },
                    }],
                    membershipId: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.membershipId == null || this.dataToView.membershipId == '' || this.dataToView.membershipId == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    reviewer: [ { required: true, message: '请填写审核人', trigger: 'change',}],
                },
                tableHeight:10,
                membershipList:[],
                typeList:[],
                injuryLeveList:[],
                // api
                standardSelectModal:false,
                queryUrl:Api.briefing,
                deleteUrl:Api.deleteMonthly,
                updateUrl:Api.updateMonthly,
                saveUrl:Api.saveMonthly,
            }
        },
        mounted() {
            this.$http.get(Api.queryCodeDetailBySortId + '/MEM-000001', {params: {}}).then((res) => {
                this.membershipList = res.data.data;
            });
            this.$http.get(Api.queryCodeDetailBySortId + '/ACC-000001', {params: {}}).then((res) => {
                this.typeList = res.data.data;
            });
            this.$http.get(Api.queryCodeDetailBySortId + '/1000001019', {params: {}}).then((res) => {
                this.injuryLeveList = res.data.data;
            });
            this.setTableHeight();
            this.query();
        },
        methods:{

            ...pageCommonFunction,
            deleteData(params) {
                this.deleteDateById(params.row.id);
            },
            onSelectFieldQueryDateRange(data, filed) {
                if (data[0] === "" || data[1] === "") {
                    this.dataToQuery[filed + 'Start'] = null;
                    this.dataToQuery[filed + 'End'] = null;
                } else {
                    this.dataToQuery[filed + 'Start'] = data[0] + ' 00:00:00';
                    this.dataToQuery[filed + 'End'] = data[1] + ' 23:59:59';
                }
            },
            downloadFile(guideId, file) {
                let url = this.fileUrl + '/file/' + file.id;
                this.$http.get(url, {
                    responseType: 'blob'      //告诉服务器我们需要的响应格式
                }).then((res) => {
                    console.log(res)
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
                    });
                    aLink.href = URL.createObjectURL(blob)
                    aLink.download = file.fileName //标题
                    aLink.click()
                    document.body.appendChild(aLink)
                })
            },
            formatDate(date, fmt) {
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                let o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (let k in o) {
                    if (new RegExp(`(${k})`).test(fmt)) {
                        let str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
                    }
                }
                return fmt;
            },
            padLeftZero(str) {
                return ('00' + str).substr(str.length);
            },
            getFiles() {
                let url = this.fileUrl + '/' + this.InputData.briefId + '/files/guideFile'
                this.$http.get(url).then((res) => {
                    if (res.data.result == "success") {
                        this.uploadList = res.data.data
                    }
                })
            },
            query() {
                this.dataToQuery.procinstState = '3';
                this.dataToQuery.injuryLevels ="";
                this.dataToQuery.memberships ="";

                this.injuryLevels.forEach(item =>{

                    this.dataToQuery.injuryLevels += item+","
                });
                this.memberships.forEach(item =>{

                    this.dataToQuery.memberships += item+","
                });
              this.query1()
            },
            selectSafeLevel(row){
                this.dataToView.safeLevelId = row.value;
                this.dataToView.safeLevel= row.label;
            },
            selectstdRank(stdRank) {
                this.dataToView.safeRankId = stdRank.value;
                this.dataToView.safeRank= stdRank.label;
            },
            selectstdIndustry(row){
                this.dataToView.industryId = row.value;
                this.dataToView.industry= row.label;
            },
            submit(name) {
                this.submitBase(name);
            },
            createEmptyDataToAdd() {
                return{
                    age:0,
                    daysWokrOff: 0
                }
            },
            reseter() {
                this.dataToQuery = {};
                this.sartDateQuery = [];
                this.memberships = [];
                this.injuryLevels = [];
                this.$refs.queryOrgCascader.resetCurrentOrg();
                this.dataToQuery.procinstState = '3';
                this.query1()
            },
            setOrgId(data) {
                this.dataToView.reportOrgId = data[data.length - 1];
            },
            setOrgName(data) {
                this.dataToView.reportOrgName = data;
            },
            selectStandard(row){
                this.standardSelectModal = false;
                this.dataToView.victim = row.victim;
                this.dataToView.reportId = row.briefId;
                this.dataToView.gender = row.gender;
                this.dataToView.age = row.age;
                this.dataToView.injured = row.injured;
                this.dataToView.position = row.position;
                this.dataToView.accTypeId = row.accTypeId;
                this.dataToView.sartDate = row.sartDateStr;
                this.dataToView.injuryLevelId = row.injuryLevelId;
                this.dataToView.membershipId = row.membershipId;

            },
            openSelect() {
                this.standardSelectModal = true
            },

        },
        watch:{

        },

    }
</script>

<style lang='css' scoped>
    @import '../../../../index.css';
</style>
